#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 1005;

int n, m;
string s, t;
int dp[N][N];
const int SAME = 0, INSERT = 1, DELETE = 2, REPLACE = 3;
int pre[N][N];  // 0 same 1 insert 2 delete 3 replace
void solve() {
  cin >> s >> t;
  n = s.size(), m = t.size();
  s = ' ' + s;
  t = ' ' + t;
  memset(dp, 0x3f, sizeof(dp));
  dp[0][0] = 0;
  rep(i, 1, m) dp[0][i] = i, pre[0][i] = INSERT;
  rep(i, 1, n) {
    dp[i][0] = i;
    pre[i][0] = DELETE;
    rep(j, 1, m) {
      if (s[i] == t[j]) {
        dp[i][j] = dp[i - 1][j - 1];
        pre[i][j] = SAME;
        continue;
      }
      // insert
      if (dp[i][j] > dp[i][j - 1] + 1) {
        dp[i][j] = dp[i][j - 1] + 1;
        pre[i][j] = INSERT;
      }
      // delete
      if (dp[i][j] > dp[i - 1][j] + 1) {
        dp[i][j] = dp[i - 1][j] + 1;
        pre[i][j] = DELETE;
      }
      // replace
      if (dp[i][j] > dp[i - 1][j - 1] + 1) {
        dp[i][j] = dp[i - 1][j - 1] + 1;
        pre[i][j] = REPLACE;
      }
    }
  }
  cout << dp[n][m] << endl;
  int x = n, y = m;
  while (x || y) {
    int act = pre[x][y];
    if (act == SAME) {
      x--, y--;
    } else if (act == INSERT) {
      cout << "INSERT " << x + 1 << ' ' << t[y] << endl;
      y--;
    } else if (act == DELETE) {
      cout << "DELETE " << x << endl;
      x--;
    } else {
      cout << "REPLACE " << x << ' ' << t[y] << endl;
      x--, y--;
    }
  }
  return;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t = 1;
  while (t--) solve();
  return 0;
}